package com.gxuwz.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.gxuwz.dao.IUserInfoDao;
import com.gxuwz.entity.SysUser;

@Repository("userInfoDao")
public class UserInfoDaoImpl extends HibernateDaoSupport implements
		IUserInfoDao {

	@Resource(name = "sessionFactory")
	public void setSuperSessionFactory(SessionFactory sessionFactory) {
		super.setSessionFactory(sessionFactory);
	}

	@Override
	public SysUser getUserByName(String username) {
		Query query = this.getSession().createQuery(
				"from SysUser where user_name = ?");
		query.setString(0, username);
		SysUser user = (SysUser) query.uniqueResult();
		if (user == null) {
			return null;
		}else{
			return user;
		}
	}

}
